/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       terraintile.h
 * Author:     karooolek
 * Created on: Jun 28, 2009
 *
 **********************************************************************************************************************/

#ifndef TERRAINTILE_H_
#define TERRAINTILE_H_

#include "terrain.h"

namespace mGameEngine
{
namespace Game
{

// terrain class prototype
class Terrain;

/**
 * Single terrain tile.
 * Terrain is partitioned into many tiles.
 */
class TerrainTile: public Graphics::Mesh
{
protected:
    /**
     * Parent terrain.
     */
    Terrain *_terrain;

    /**
     * Position;
     */
    Vector2 _position;

    /**
     * Level of detail.
     */
    uint8 _lod;

public:
    /**
     * Create new tile with specified terrain and position
     * @param terrain parent terrain.
     * @param position position.
     * @param lod LOD level.
     */
    TerrainTile(Terrain *terrain, const Vector2 &position, uint8 lod = 0);

    /**
     * Destroy tile.
     */
    virtual ~TerrainTile();

    /**
     * Generate lower level of deatail meshes.
     * Actual lower level of detail meshes will be overriden.
     * @param levels number of lower LOD meshes to generate.
     * @param vertReduction percentage of deleted vertices, unused.
     */
    virtual void generateLowerLODMeshes(uint8 levels,
                                        float vertReduction = 0.5f);
};

}
}

#endif // TERRAINTILE_H_
